﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Config;
using gfPage;

namespace IYAKASAPortal.Login
{
    public partial class LoginAJList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                btnSearch_Click(sender, e);
            }
        }


        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string strKeywords = txtKeywords.Text;

            string strSql = "select ID,HPHM,VIN,ZYWLB,DLRQ = case when DLRQ is null then  '未登录' when DLRQ is not null then '[已登录]' end  from LOGIN_VEHICLE_INFO ";

            if (strKeywords.Length > 0)
            {
                strSql += " where ";
                strSql += "HPHM like '%" + strKeywords + "%'";
                strSql += " or VIN like '%" + strKeywords + "%'";
            }

            strSql += " order by ID asc";

            DataTable m_dtTable = new DataTable();
            GreatPager1.BindDataTablePage(ref m_dtTable, AppConfig.g_strConnectionStringSqlClient, strSql, 20);

            rptList.DataSource = m_dtTable;
            rptList.DataBind();

            m_dtTable.Dispose();
        }

        protected void GreatPager1_PageIndexChanging(object sender, gfPage.PagerEventArgs e)
        {
            GreatPager1.PageIndex = e.NewPageIndex;

            DataTable m_dtTable = GreatPager1.BindDataTablePage();
            rptList.DataSource = m_dtTable;
            rptList.DataBind();
        }


        protected void btnSearchAll_Click(object sender, EventArgs e)
        {
            txtKeywords.Text = "";
            btnSearch_Click(sender, e);
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {

        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {

        }
    }
}